package com.hashcoding.eyes.data.entity;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Photo
 *
 * @author Maochuan
 * @date 2016-02-03
 */
public class Photo implements Parcelable {
    public int id;
    public String url;
    public String description;
    public String userID;
    public String title;
    public boolean isStart;

    private static int total = 0;

    public Photo(String u, String a, String t, String d, boolean s) {
        userID = u;
        url = a;
        title = t;
        description = d;
        isStart = s;
        id = total++;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(url);
        dest.writeString(description);
        dest.writeString(userID);
        dest.writeString(title);
        dest.writeByte(isStart ? (byte) 1 : (byte) 0);
    }

    protected Photo(Parcel in) {
        this.id = in.readInt();
        this.url = in.readString();
        this.description = in.readString();
        this.userID = in.readString();
        this.title = in.readString();
        this.isStart = in.readByte() == 1;
    }

    public static final Creator<Photo> CREATOR = new Creator<Photo>() {
        public Photo createFromParcel(Parcel source) {
            return new Photo(source);
        }

        public Photo[] newArray(int size) {
            return new Photo[size];
        }
    };
}
